home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 8.5 KB | 276 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: DrawPart.h
- // Release Version: $ 1.0d1 $
- //
- // Author: Henri Lamiraux
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef DRAWPART_H
- #define DRAWPART_H
-
- #ifndef DRAWDEF_H
- #include "DrawDef.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWPARTING_H
- #include "FWParting.h"
- #endif
-
- // ----- OPF Foundation Includes -----
-
- #ifndef BCCOLLU_H
- #include <BCCollU.h>
- #endif
-
- // ----- Graphic Includes -----
-
- #ifndef FWCOLOR_H
- #include <FWColor.h>
- #endif
-
- //==============================================================================
- // •• Forward Declarations
- //==============================================================================
-
- class CDrawSelection;
- class CBaseShape;
- class FW_CFloatingWindow;
- class CLink;
- class CProxyShape;
- class CPaletteFacet;
- class CToolFacet;
- class BC_CUnmanaged;
-
- //==============================================================================
- // •• Constants
- //==============================================================================
-
- const short kArrangeMenu = 4;
- const short kPenSizeMenu = kArrangeMenu + 1;
- const short kWindowMenu = kPenSizeMenu + 1;
-
- // ----- Commands -----
- const XMPCommandID cMoveForward = 1;
- const XMPCommandID cMoveToFront = cMoveForward + 1;
- const XMPCommandID cMoveBackward = cMoveToFront + 1;
- const XMPCommandID cMoveToBack = cMoveBackward + 1;
- const XMPCommandID cFreeze = cMoveToBack + 1;
- const XMPCommandID cDefrost = cFreeze + 1;
-
- const XMPCommandID cPen1 = cDefrost + 1;
- const XMPCommandID cPen2 = cPen1+1;
- const XMPCommandID cPen3 = cPen2+1;
- const XMPCommandID cPen4 = cPen3+1;
- const XMPCommandID cPen5 = cPen4+1;
-
- const XMPCommandID cHideShowTools = cPen5+1;
- const XMPCommandID cHideShowPalette = cHideShowTools+1;
-
- const unsigned short kToolWidth = 43;
- const unsigned short kToolHeight = 64;
- const unsigned short kSelectorHeight = 12;
- const unsigned short kColorSelectorWidth = 37;
- const unsigned short kColorSelectorHeight = 30;
- const unsigned short kToolsWindowWidth = 2 + kToolWidth + 2;
- const unsigned short kToolsWindowHeight = 2 + kToolHeight + 4 + kSelectorHeight + 8 + kColorSelectorHeight + 5;
-
- const unsigned short kPaletteWindowWidth = 2 + 32 * 9 + 1 + 2;
- const unsigned short kPaletteWindowHeight = 2 + 8 * 9 + 1 + 2;
-
- const unsigned short kSelectTool = 1;
- const unsigned short kLine = 2;
- const unsigned short kRectangle = 3;
- const unsigned short kOval = 4;
- const unsigned short kRoundRect = 5;
- const unsigned short kArc = 6;
-
- //==============================================================================
- // •• class CDrawPart
- //==============================================================================
-
- class CDrawPart : public FW_CEmbeddingPart
- {
- //------------------------------------------------------------------------------
- // • Initialization/Destruction
- //
- public:
- CDrawPart();
- virtual ~ CDECL CDrawPart();
-
- virtual void Initialize();
- virtual void AddProperties(XMPStorageUnit* storageUnit);
- virtual void Release();
-
- virtual XMPValueType GetContentPropertyValueType() const;
-
- //------------------------------------------------------------------------------
- // • Inherited API
- //
- public:
- virtual FW_CFrame* NewFrame(XMPFrame* xmpFrame, XMPTypeToken presentation);
-
- virtual void ExternalizeContent(XMPStorageUnit* storageUnit);
- virtual void InternalizeContent(XMPStorageUnit* storageUnit);
-
- virtual FW_Boolean DoMenuEvent(XMPMenuBar *menuBar, XMPCommandID commandID);
- virtual void DoAdjustMenus(XMPMenuBar* menuBar);
-
- virtual FW_CProxyRun* NewProxyRun();
-
- virtual XMPTypeToken GetDefaultPresentation() const;
-
- //------------------------------------------------------------------------------
- // • New API
- //
- public:
- CProxyShape* NewProxyShape(XMPPart* xmpPart, const FW_CRect& shapeRect, FW_Boolean invalidate);
-
- void DeleteShape(CBaseShape* shape);
- void AddShape(CBaseShape* shape);
- void AddShapeAfter(CBaseShape* after, CBaseShape* shape);
-
- BC_TUnboundedCollection<CBaseShape*, BC_CUnmanaged>* GetShapeList() const;
- XMPCoordinate GetPenSize() const;
- unsigned short GetFillFrame() const;
-
- void CheckTool(unsigned short oldTool, unsigned short newTool);
- void CheckFillFrame(unsigned short oldFillFrame, unsigned short newFillFrame);
- void SetFillFrame(unsigned short fillFrame);
-
- void GetFillColor(FW_CColor* color) const;
- void GetPenColor(FW_CColor* color) const;
-
- void SetFillColor(const FW_CColor& color);
- void SetPenColor(const FW_CColor& color);
-
- void MoveForward();
- void MoveBackward();
- void MoveToFront();
- void MoveToBack();
-
- void SetTool(unsigned short newTool);
- unsigned short GetTool() const;
-
- virtual FW_CSelection* NewSelection();
-
- XMPTypeToken GetMainPresentation() const;
- XMPTypeToken GetPalettePresentation() const;
- XMPTypeToken GetToolPresentation() const;
-
- CBaseShape* NewShape(unsigned short shapeType);
-
- private:
- BC_TUnboundedCollection<CBaseShape*, BC_CUnmanaged>* ExtractSelection();
-
- //------------------------------------------------------------------------------
- // • Data Members
- //------------------------------------------------------------------------------
- private:
- MenuHandle fArrangeMenu;
- MenuHandle fPenSizeMenu;
- MenuHandle fWindowMenu;
-
- FW_CFloatingWindow* fPaletteWindow;
- FW_CFloatingWindow* fToolsWindow;
-
- BC_TUnboundedCollection<CBaseShape*, BC_CUnmanaged>* fShapeList;
- unsigned short fTool;
- XMPCoordinate fCurrentPenSize;
- unsigned short fFillFrame;
- FW_CColor fFillColor;
- FW_CColor fPenColor;
-
- unsigned short fNbEmbedded;
-
- XMPTypeToken fPalettePresentation;
- XMPTypeToken fToolPresentation;
- XMPTypeToken fMainPresentation;
-
- CDrawSelection* fDrawSelection;
- };
-
- //==============================================================================
- // •• Inlines
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // • CDrawPart::GetShapeList
- //------------------------------------------------------------------------------
- inline BC_TUnboundedCollection<CBaseShape*, BC_CUnmanaged>* CDrawPart::GetShapeList() const
- {
- return fShapeList;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawPart::GetPenSize
- //------------------------------------------------------------------------------
- inline XMPCoordinate CDrawPart::GetPenSize() const
- {
- return fCurrentPenSize;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawPart::GetFillFrame
- //------------------------------------------------------------------------------
- inline unsigned short CDrawPart::GetFillFrame() const
- {
- return fFillFrame;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawPart::GetTool
- //------------------------------------------------------------------------------
- inline unsigned short CDrawPart::GetTool() const
- {
- return fTool;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawPart::GetMainPresentation
- //------------------------------------------------------------------------------
- inline XMPTypeToken CDrawPart::GetMainPresentation() const
- {
- return fMainPresentation;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawPart::GetPalettePresentation
- //------------------------------------------------------------------------------
- inline XMPTypeToken CDrawPart::GetPalettePresentation() const
- {
- return fPalettePresentation;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawPart::GetToolPresentation
- //------------------------------------------------------------------------------
- inline XMPTypeToken CDrawPart::GetToolPresentation() const
- {
- return fToolPresentation;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawPart::GetFillColor
- //------------------------------------------------------------------------------
- inline void CDrawPart::GetFillColor(FW_CColor* color) const
- {
- *color = fFillColor;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawPart::GetPenColor
- //------------------------------------------------------------------------------
- inline void CDrawPart::GetPenColor(FW_CColor* color) const
- {
- *color = fPenColor;
- }
-
- #endif
-